﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.ComponentModel;

namespace SAR
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            this.InitializeComponent();
            this.OverallArgumentTab.Visibility = Visibility.Visible;
			//窗口居中
			WindowStartupLocation = WindowStartupLocation.CenterScreen;

            // 在此点下面插入创建对象所需的代码。
        }

        #region 界面相关的必须代码

        /// <summary>
        /// 窗口拖动
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Grid_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                this.DragMove();
            }
        }

        /*
        * 窗口控制按钮
        */
        private void WindowsButton_MinClick(object sender, MouseButtonEventArgs e)
        {
            this.WindowState = WindowState.Minimized;
        }
        private void WindowsButton_MaxClick(object sender, MouseButtonEventArgs e)
        {
            
            if (this.WindowState ==  WindowState.Maximized)
            {
                this.WindowState = WindowState.Normal;
                return;
            }

            this.WindowState = WindowState.Maximized;

        }
        private void WindowsBotton_CloseClick(object sender, MouseButtonEventArgs e)
        {
            this.Close();
        }

        //被点击的菜单名字，设置给TabControl，用于页面寻址
        private string menuItemName = "OverallArgument";
        public string MenuItemName
        {
            get
            {
                return menuItemName;
            }
            set
            {
                this.menuItemName = value;
            }
        }
        


        /// <summary>
        /// 菜单相关代码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItem1_Click(object sender, MouseButtonEventArgs e)
        {
            menuItem1.SARIsSelected = true;
            menuItem2.SARIsSelected = false;
            menuItem3.SARIsSelected = false;
            menuItem4.SARIsSelected = false;
            menuItem5.SARIsSelected = false;
            menuItemName = "OverallArgument";

            //显示对应选项卡
            this.OverallArgumentTab.Visibility = Visibility.Visible;
            this.HuiboMoniTab.Visibility = Visibility.Hidden;
            this.ChengxiangChuliTab.Visibility = System.Windows.Visibility.Hidden;
            this.TuXiangPingGuTab.Visibility = Visibility.Hidden;
            this.OverallArgumentTab.SARCurrentTabIndex = 0;
            MainWindowPage.Source = new Uri("Pages/OverallArgument/Design/DesignPageControl.xaml", UriKind.Relative);            
        }

        private void MenuItem2_Click(object sender, MouseButtonEventArgs e)
        {

            menuItem1.SARIsSelected = false;
            menuItem2.SARIsSelected = true;
            menuItem3.SARIsSelected = false;
            menuItem4.SARIsSelected = false;
            menuItem5.SARIsSelected = false;
            this.OverallArgumentTab.Visibility = Visibility.Hidden;
            this.HuiboMoniTab.Visibility = Visibility.Visible;
            this.ChengxiangChuliTab.Visibility = System.Windows.Visibility.Hidden;
            this.TuXiangPingGuTab.Visibility = Visibility.Hidden;
            menuItemName = "HuiboMoNi";
            MainWindowPage.Source = new Uri("Pages/HuiboMoni/HuiboMoniPageControl.xaml", UriKind.Relative); 

        }

        private void MenuItem3_Click(object sender, MouseButtonEventArgs e)
        {
            menuItem1.SARIsSelected = false;
            menuItem2.SARIsSelected = false;
            menuItem3.SARIsSelected = true;
            menuItem4.SARIsSelected = false;
            menuItem5.SARIsSelected = false;
            this.OverallArgumentTab.Visibility = Visibility.Hidden;
            this.HuiboMoniTab.Visibility = Visibility.Hidden;
            this.ChengxiangChuliTab.Visibility = System.Windows.Visibility.Visible;
            this.TuXiangPingGuTab.Visibility = Visibility.Hidden;
            menuItemName = "ChengXiangChuLi";
            MainWindowPage.Source = new Uri("Pages/ChengXiangChuLi/ChengXiangChuLiPageControl.xaml", UriKind.Relative); 

        }

        private void MenuItem4_Click(object sender, MouseButtonEventArgs e)
        {
            menuItem1.SARIsSelected = false;
            menuItem2.SARIsSelected = false;
            menuItem3.SARIsSelected = false;
            menuItem4.SARIsSelected = true;
            menuItem5.SARIsSelected = false;
            this.OverallArgumentTab.Visibility = Visibility.Hidden;
            this.HuiboMoniTab.Visibility = Visibility.Hidden;
            this.ChengxiangChuliTab.Visibility = System.Windows.Visibility.Hidden;
            this.TuXiangPingGuTab.Visibility = Visibility.Visible;
            menuItemName = "TuXiangPingGu";
            this.TuXiangPingGuTab.SARCurrentTabIndex = 0;
            MainWindowPage.Source = new Uri("Pages/TuXiangPingGu/DianMuBiao/DianMuBiaoPageControl.xaml", UriKind.Relative); 

        }

        private void MenuItem5_Click(object sender, MouseButtonEventArgs e)
        {
            menuItem1.SARIsSelected = false;
            menuItem2.SARIsSelected = false;
            menuItem3.SARIsSelected = false;
            menuItem4.SARIsSelected = false;
            menuItem5.SARIsSelected = true;
            this.OverallArgumentTab.Visibility = Visibility.Hidden;
            this.HuiboMoniTab.Visibility = Visibility.Hidden;
            this.ChengxiangChuliTab.Visibility = System.Windows.Visibility.Hidden;            
            menuItemName = "TuXiangFanYan";

            //测试代码，在正式版中应该删掉
            this.MainWindowPage.Source = new Uri("Pages/TestPage6.xaml", UriKind.Relative);
        }
        #endregion        

        //总体参数Tab切换事件
        private void OverallArgumentTab_SARIndexChanged(int newIndex)
        {
            string framePathPrefix = "Pages/" + menuItemName + "/";
            if (newIndex == 0)
            {
                framePathPrefix += "Design/Design";
            }
            else
            {
                framePathPrefix += "Analyze/Analyze";
            }
            this.MainWindowPage.Source = new System.Uri(framePathPrefix + "PageControl.xaml", UriKind.Relative);
        }

        private void TuXiangPingGuTab_SARIndexChanged(int newIndex)
        {
            string framePathPrefix = "Pages/" + menuItemName + "/";
            if (newIndex == 0)
            {
                framePathPrefix += "DianMuBiao/DianMuBiao";
            }
            else
            {
                framePathPrefix += "MianMuBiao/MianMuBiao";
            }
            this.MainWindowPage.Source = new System.Uri(framePathPrefix + "PageControl.xaml", UriKind.Relative);
        
        }

    }
}